<template>
  <div class="app-container">
    <!-- 查询 -->
    <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false" v-if="isHeaderDisplay">
      <template slot="search">
        <el-form-item label="项目名称">
          <el-input v-model="queryParam.qry_projectname" placeholder="请输入名称关键词" @keyup.enter.native="doQuery"></el-input>
        </el-form-item>
        <el-form-item label="项目级别">
          <el-select v-model="projectlevelList" multiple placeholder="请选择项目级别" style="width:190px" @change="doQueryConcatProjectLevel">
            <el-option v-for="item in codeModel.projectlevelList" :key="item.code" :label="item.name" :value="item.code">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目经理">
          <el-input v-model="queryParam.qry_projectmanager" placeholder="工号或姓名" @keyup.enter.native="doQuery">
          </el-input>
        </el-form-item>
      </template>
    </tl-list-search>
    <div>
      <!-- 列表选择 -->
      <div class="table-alert-div" ref="selector">
        <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
          <template slot="title">
            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
          </template>
        </el-alert>
      </div>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :row-style="tableRowStyle" :height="tableHeight" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <el-table-column type="index" label="序号" width="50px" align="center"></el-table-column>
        <el-table-column prop="deptname" label="所属部门" width="95px" sortable="custom" sort-by="deptname" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="projectcode" label="项目编号" width="125px" sortable="custom" sort-by="projectcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="projectname" label="项目名称" min-width="300px" sortable="custom" sort-by="projectname" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispprojectlevel" label="项目级别" width="80px" sortable="custom" sort-by="projectlevel" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="projectmanager" label="项目经理" width="80px" sortable="custom" sort-by="projectmanager" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispprojectstate" label="项目状态" width="80px" sortable="custom" sort-by="projectstate" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="bidcycle" label="项目周期(天)" width="105px" sortable="custom" sort-by="bidcycle" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="planstartdate" label="计划开始日期" width="105px" sortable="custom" sort-by="planstartdate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column prop="planenddate" label="计划结束日期" width="105px" sortable="custom" sort-by="planenddate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column prop="actualenddate" label="实际结项日期" width="105px" sortable="custom" sort-by="actualenddate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column prop="projectendmoney" label="结项金额(万元)" width="115px" sortable="custom" :formatter="moneyFormatTec" sort-by="projectendmoney" align="right" header-align="center" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column prop="sponsor" label="Sponsor" width="75px" sortable="custom" sort-by="sponsor" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="owner" label="Owner" width="75px" sortable="custom" sort-by="owner" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="background" label="项目背景概述" width="240px" sortable="custom" sort-by="background" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="target" label="项目目标" width="200px" sortable="custom" sort-by="target" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="summary" label="总体策划" width="200px" sortable="custom" sort-by="summary" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <!-- <el-table-column prop="latestphase" label="最新阶段" width="150px" sortable="custom" sort-by="latestphase" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispstate" label="状态" width="100px" sortable="custom" sort-by="state" align="center" header-align="center" :show-overflow-tooltip="true">
        <template v-slot="scope">
            <el-tag :type="changeStateType(scope.row.state)">
              {{ scope.row.dispstate }}
            </el-tag>
          </template>
        </el-table-column> -->
        <el-table-column label="操作" width="100px" v-slot="scope" fixed="right">
          <el-dropdown trigger="hover">
            <el-button type="text" icon="el-icon-s-operation" style="margin-left:10px">更多<i class="el-icon-arrow-down el-icon--right"></i></el-button>
            <el-dropdown-menu>
              <el-dropdown-item icon="el-icon-view" @click.native="openViewDialog('editForm', scope.row.id)">查看</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" type="flex" ref="pager" align="bottom">
        <el-col :span="12" style="margin-bottom:5px;">
          <el-col style="background-color:#D80A1E;height: 20px;width:20px;margin-left:10px" :offset="0"> </el-col>
          <el-col class="projectStateContext" :offset="0">
            项目超期
          </el-col>
          <el-col style="background-color:#FF8C2E;height: 20px;width:20px" :offset="0"> </el-col>
          <el-col class="projectStateContext" :offset="0">
            里程碑超期
          </el-col>
          <el-col style="background-color:#0000FF;height: 20px;width:20px" :offset="0"> </el-col>
          <el-col class="projectStateContext" :offset="0">
            流程超期
          </el-col>
          <el-col style="background-color:#B8860B;height: 20px;width:20px" :offset="0"> </el-col>
          <el-col class="projectStateContext" :offset="0">
            任务超期
          </el-col>
        </el-col>
        <el-col :span="12">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
        </el-col>
      </el-row>
      <index-comp-for-query ref="indexCompForQuery" :projectcode="projectcode" :fromIndexType="'query'"></index-comp-for-query>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import indexCompForQuery from "../gpmProjectInfo/indexForQueryComp"
import { checkPermission } from '@tapui/utils/permission'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
import { filterObjectNull, rmbFormat } from '@tapui/utils/util'
export default {
  name: 'sdProjectQuery',
  mixins: [mixin_list],
  components: { indexCompForQuery },
  data() {
    return {
      projectlevelList: [],
      description: '立项归档-列表查询',
      urlPrefix: '/sd/project/',
      url: {
        queryCodeList: '/sd/project/dataCodeList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'applydate',
        sord: 'desc'
      },
      queryParam: {
        // 查询已结项的项目，包括正常结项和异常结项
        qry_projectstate: '2,8',
        qry_open: '1'
      }
    }
  },
  methods: {
    // 项目级别多选框
    doQueryConcatProjectLevel(data) {
      if (data.length > 0) {
        this.queryParam.qry_projectlevel = data
          .map((item) => {
            return "'" + item + "'"
          })
          .join(',')
      } else {
        this.queryParam.qry_projectlevel = null
      }
    },
    tableRowStyle(row, index) {
      if (row.row.abnormalstate === 30) {
        return { "background-color": "rgb(235,75,75)", color: "white" }
      } else if (row.row.abnormalstate === 20) {
        return { "background-color": "rgb(255,140,46)", color: "white" }
      } else if (row.row.abnormalstate === 10) {
        return { "background-color": "rgb(184,134,11)", color: "white" }
      } else if (row.row.abnormalstate === 15) {
        return { "background-color": "#0000FF", color: "white" }
      }
    },
    /** 表格双击事件 */
    doRowDbClick(row, column, event) {
      this.openViewDialog('indexCompForQuery', row[this.$refs.mainTable.rowKey])
    }
    /** 获取查询参数 */
    // getQueryParams() {
    //   let param = {}
    //   if (this.superQueryParams) {
    //     param['superQueryParams'] = encodeURI(this.superQueryParams)
    //   }
    //   Object.assign(param, this.queryParam, this.sorterInfo, this.filtersInfo)
    //   param.currentPage = this.pageInfo.currentPage
    //   param.pageSize = this.pageInfo.pageSize
    //   if (this.projectlevelList) {
    //     param.qry_projectlevel = this.projectlevelList.join(',')
    //   }
    //   param.qry_projectstate = '2,8'// 查询已结项的项目，包括正常结项和异常结项
    //   param.qry_open = '1'
    //   return filterObjectNull(param)
    // }
  }
}
</script>

<style scoped>
  .app-container >>> .el-table tbody tr.hover-row > td {
    background-color: transparent !important;
  }
  .app-container {
    height: 100%;
    padding: 10px;
    margin: 12px;
    background: white;
    border-radius: 5px;
  }
</style>

